//
//  MapViewController.m
//  RealatorView
//
//  Created by Ricky Jones on 2/2/09.
//  Copyright 2009 Vaporsoftware. All rights reserved.
//

#import "MapViewController.h"

@implementation MapViewController

@synthesize CordsToShow = _cordsToShow;
@synthesize WebView = _webView;
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/


- (void)loadView
{
	// the base view for this view controller
	UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
	contentView.backgroundColor = [UIColor whiteColor];
	
	// important for view orientation rotation
	contentView.autoresizesSubviews = YES;
	contentView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);	
	
	self.view = contentView;
	
	[contentView release];
	
	CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
//	webFrame.origin.y += kTopMargin + 5.0;	// leave from the URL input field and its label
	webFrame.size.height -= 40.0;
	_webView = [[UIWebView alloc] initWithFrame:webFrame];
	_webView.backgroundColor = [UIColor whiteColor];
	_webView.scalesPageToFit = YES;
	_webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
	_webView.delegate = self;
	[self.view addSubview: _webView];
	
	NSString *latlong =  [NSString stringWithFormat:@"%d,%d",_cordsToShow.latitude,_cordsToShow.longitude];
	NSString *url = [NSString stringWithFormat: @"http://maps.google.com/maps?ll=%@",
					 [latlong stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
	
	[_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
}




// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad 
 {

 }

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
    [super dealloc];
}


@end
